package de.andreavicentini.teatralia.generate;

import org.magiclabs.htmlx.*;
import de.andreavicentini.teatralia.pages.*;
import de.andreavicentini.teatralia.pages.events.*;
import de.andreavicentini.teatralia.pages.repertoire.*;

public class EventRenderer<T> implements IRenderer<T> {
  protected static String nl;
  public static synchronized EventRenderer create(String lineSeparator)
  {
    nl = lineSeparator;
    EventRenderer result = new EventRenderer();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = NL + NL;
  protected final String TEXT_3 = NL;
  protected final String TEXT_4 = NL + "<p>" + NL + "<a href=\"";
  protected final String TEXT_5 = "#";
  protected final String TEXT_6 = "\">";
  protected final String TEXT_7 = "</a> " + NL;
  protected final String TEXT_8 = NL + "(<a href=\"";
  protected final String TEXT_9 = "#";
  protected final String TEXT_10 = "\">";
  protected final String TEXT_11 = "</a>)";
  protected final String TEXT_12 = NL + "<br>";
  protected final String TEXT_13 = NL;
  protected final String TEXT_14 = "<br><br>";
  protected final String TEXT_15 = NL;
  protected final String TEXT_16 = NL + "</p>" + NL + "</div><p>";
  protected final String TEXT_17 = NL;

	public String generate(TeatraliaPage page, T argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     
Event event = (Event) argument;
IPlay play = event.getPlay();
TeatraliaSiteModel site = (TeatraliaSiteModel) page.getArea().getSiteModel();
 
    stringBuffer.append(TEXT_2);
    stringBuffer.append(TEXT_3);
    stringBuffer.append( new ToggleHeader(event.hashCode() + "", event.getDate().toString(), play.getStyle()) );
    stringBuffer.append(TEXT_4);
    stringBuffer.append( site.repertoire.getPage() );
    stringBuffer.append(TEXT_5);
    stringBuffer.append( play.hashCode() );
    stringBuffer.append(TEXT_6);
    stringBuffer.append( play.getTitle() );
    stringBuffer.append(TEXT_7);
     if (play instanceof Play) { 
    stringBuffer.append(TEXT_8);
    stringBuffer.append( site.repertoire.getPage() );
    stringBuffer.append(TEXT_9);
    stringBuffer.append( ((Play) play).getAuthor().getLastName() );
    stringBuffer.append(TEXT_10);
    stringBuffer.append( ((Play) play).getAuthor() );
    stringBuffer.append(TEXT_11);
     } 
    stringBuffer.append(TEXT_12);
    stringBuffer.append(TEXT_13);
    stringBuffer.append( new LocationLink(event.getLocation()) );
    stringBuffer.append(TEXT_14);
    stringBuffer.append(TEXT_15);
    stringBuffer.append( new FotosLink(event.getFotos()) );
    stringBuffer.append(TEXT_16);
    stringBuffer.append(TEXT_17);
    return stringBuffer.toString();
  }
}